<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
//$iso = split( '=', _ISO );
//echo '<?xml version="1.0" encoding=UTF-8"?' .'>';

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: edit_match.tpl.php 1201 2008-07-08 16:08:26Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 


global $project, $joomleague, $database;

if (!isset($project)) $project = &$joomleague;
$table_config=$project->getTemplateConfig("show_table.tpl");

/* now managed directly in results 
// regular 'inline' output
if ( ( !isset($overall_config['results_below']) || $overall_config['results_below'] == 0 ) &&
	   (!isset($overall_config['edit_results_below']) || $overall_config['edit_results_below']==0) ) 
{
  if($project->allow_add_time)
  {
  	$xrounds = array();
  	$xrounds[] = mosHTML::makeOption(0, _JL_RESULTS_REGULAR);
  	$xrounds[] = mosHTML::makeOption(1, _JL_RESULTS_OVERTIME);
  	$xrounds[] = mosHTML::makeOption(2, _JL_RESULTS_PENALTY); 
  	$mstl = mosHTML::selectList( $xrounds, "match_result_type$match->match_id", 'class="inputbox" size="1"','value', 'text', $match->match_result_type );
  	unset($xrounds);  	
  }
}
*/
?>
<script language="JavaScript" src="<?php echo _JOOMLA_JL_LIVE_SITE; ?>/includes/js/JSCookMenu_mini.js" type="text/javascript"></script>
<script language="JavaScript" src="<?php echo _JOOMLA_JL_LIVE_SITE; ?>/administrator/includes/js/ThemeOffice/theme.js" type="text/javascript"></script>
<script language="JavaScript" src="<?php echo _JOOMLA_JL_LIVE_SITE; ?>/includes/js/joomla.javascript.js" type="text/javascript"></script>

<?php
$mainframe->set( 'loadEditor', true );
if ( file_exists( _JOOMLA_JL_PATH . '/editor/editor.php' ) ) {
  include_once( _JOOMLA_JL_PATH . '/editor/editor.php' ); 
}
else {
  include_once (_JOOMLA_JL_PATH . "/libraries/joomla/html/editor.php");
}
initEditor();
?>
<!-- Score Table START -->
<div style="float:left; text-align:left;">
<table class="adminForm"">
  <!-- Header team names -->
	<tr>
		<th width="50%">&nbsp;</th>
    <th align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HOME_SHORT;?></th>
    <th>&nbsp;</th>
    <th><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_AWAY_SHORT;?></th>
	</tr>
	<!-- Header team names END -->
	<?php 
	if ((!isset($overall_config['results_below'])||$overall_config['results_below']==0) &&
	   (!isset($overall_config['edit_results_below'])||$overall_config['edit_results_below']==0)) 
  { 
    /* Now managed 'inline'
    ?>
		<tr>
			<td align="left"><?php echo jl_utf8_convert(_JL_ADMIN_EDIT_MATRIX_ROUNDS_PART_RESULT);?>:</td>
			<!-- Home team column -->
      <td align="right"> 
        <?php
        /*
        // Game parts results   
        if ($project->game_parts > 1) {     
          $partresults1=explode(";", $match->matchpart1_result_split);
          $partresults2=explode(";", $match->matchpart2_result_split);
    			
          for ($x=0;$x<($project->game_parts);$x++) 
          {
            echo ($x+1).":";
            ?>
            <input type="text" style="font-size:9px;" name="matchpart1_result_split<?php echo $match->match_id;?>[]" 
              value="<?php echo (isset($partresults1[$x])) ? $partresults1[$x] : '';?>" 
              size="3" tabindex="<?php echo 2*$x+10;?>" 
              class="inputbox" readonly />
            <br />
            <?php 
          }
        }
        // Game parts results  END
        
        // Overtime result
        if($project->allow_add_time) 
        {
          echo "OT:";
          ?>
          <input type="text" style="font-size:9px;" name="matchpart1_result_ot<?php echo $match->match_id;?>" 
            value="<?php echo (isset($match->matchpart1_result_ot)) ? $match->matchpart1_result_ot : '';?>" 
            size="3" tabindex="<?php echo 2*$project->game_parts+10;?>" 
            class="inputbox" />
          <br />
          <?php 
        } 
        // Overtime result
        ?>
      </td>
      <!-- Home team column END -->
      <!-- Middle column ":" -->
      <td align="center" style="line-height:19px; width:4px;"> 
        <?php
        for ($x=0;$x<($project->game_parts);$x++) {
       		 echo ":<br />"; 
        }
       	if($project->allow_add_time) {
        	echo ":<br />"; 
        }
        ?>
      </td>
      <!-- Middle column ":" END -->
      <!-- Away team column -->
    	<td> 
        <?php
        for ($x=0;$x<($project->game_parts);$x++) 
        { ?>
          <input type="text" style="font-size:9px;" name="matchpart2_result_split<?php echo $match->match_id;?>[]" 
            value="<?php  echo (isset($partresults2[$x])) ? $partresults2[$x] : '';?>" 
            size="3" tabindex="<?php echo 2*$x+11;?>" class="inputbox" readonly />
          <br />
          <?php 
        }
        if($project->allow_add_time) 
        {	?>
    	    <input type="text" style="font-size:9px;" name="matchpart2_result_ot<?php echo $match->match_id;?>" 
          value="<?php echo (isset($match->matchpart2_result_ot)) ? $match->matchpart2_result_ot : '';?>" 
          size="3" tabindex="<?php echo 2*$project->game_parts+11;?>" class="inputbox" />
    	    <?php 
        }
        ?>
    	</td>
      <!-- Away team column END -->
    </tr>
    <?php
    */
  	if ($project->use_legs==1) 
    {
      ?>
    	<tr>
  			<td> 
          <?php
    		  if ($table_config['alternative_legs']=="") {
            echo _JL_TABLE_LEGS;
          }
				  else {
            echo $table_config['alternative_legs'];
          }
          ?>
          : 
        </td>
        <td align="right">
		 	    <input type="text" style="font-size:9px;" name="matchpart1_legs<?php echo $match->match_id;?>" 
            value="<?php echo $match->matchpart1_legs; ?>" size="3" 
            tabindex="100" class="inputbox" />
    		</td>
    		<td align="center">:</td>
    		<td>
    		  <input type="text" style="font-size:9px;" name="matchpart2_legs<?php echo $match->match_id;?>" 
            value="<?php echo $match->matchpart2_legs; ?>" size="3" 
            tabindex="101" class="inputbox" />
    		</td>
    	</tr>
      <?php 
    }
	}
  ?>
	
	<!-- Bonus points -->
	<tr>
		<td><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_BONUS; ?></td>
		<td align="right">
      <input type="text" style="font-size:9px;" name="matchpart1_bonus<?php echo $match->match_id;?>" 
        value="<?php echo $match->matchpart1_bonus;?>" size="3" 
        tabindex="102" class="inputbox" />
    </td>
		<td align="center">:</td>
		<td>
      <input type="text" style="font-size:9px;" name="matchpart2_bonus<?php echo $match->match_id;?>" 
        value="<?php echo $match->matchpart2_bonus;?>" size="3" 
        tabindex="103" class="inputbox" />
    </td>
	</tr>
	<!-- Bonus points END -->
</table>

<!-- Score Table END -->
<br/>
<!-- Additional Details Table START -->  
<table class="adminForm">
  <!-- Publish game -->
  <tr>
    <td>
      <?php
      echo _JL_ADMIN_PUBLISHED.':';
      ?>
    </td>
    <td>
      <?php echo mosHTML::yesnoRadioList('published'.$match->match_id, '', $match->published );?>
    </td>
  </tr>
  <!-- Publish game END -->
  
  <!-- Result notice -->
  <tr>
    <td>
      <?php
      echo _JL_ADMIN_EDIT_FORM_MATCHES_RESULT_NOTICE;
      ?>
    </td>
    <td>
      <input style="font-size:9px;" type="text" name="match_result_detail<?php echo $match->match_id;?>" 
        value="<?php echo jl_utf8_convert($match->match_result_detail);?>" 
        size="30" class="inputbox" />
    </td>
  </tr>
  <!-- Result notice END -->
  
  <!-- Playground -->
  <tr>
    <td><?php echo _JL_ADMIN_EDIT_LIST_PLAYGROUNDS_PLAYGROUND.": " ?></td>
    <td><?php echo $playgroundslist; ?></td>
  </tr>
  <tr>
    <td><?php echo _JL_REPORT_CROWD;?></td>
    <td><input type="text" style="font-size:9px;" name="crowd<?php echo $match->match_id;?>" value="<?php
       echo $match->crowd;?>" size="6" class="inputbox" />
    </td>
  </tr>
  <!-- Playground END-->
  
  <!-- Referee -->
  <tr>
    <td><?php echo _JL_REPORT_REFEREE;?></td>
    <td><?php 
      echo mosHTML::selectList( $ref, 'referee_id'.$match->match_id, 'class="inputbox" style="font-size:9px;" size="1"','value', 'text', $match->referee_id );?>
    </td>
  </tr>
  <!-- Referee END -->
  
  <!-- Game Report -->
  <tr>
    <td><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_SHOW_MATCHREPORT;?></td>
    <td><?php echo mosHTML::yesnoRadioList('show_report'.$match->match_id, '', $match->show_report );?></td>
  </tr>
  <tr>
    <td colspan="2">
      <?php 
      echo _JL_REPORT_DETAIL;?>:<br /><br />
      <?php
      editorArea( 'editor1',  jl_utf8_convert($match->summary) , 'summary'.$match->match_id, '98%', '200', '50', '5' ) ;
      ?>
      <br />
      <a id="control" href="" onclick="showeditor('summary<?php echo $match->match_id;?>', 'control');return false;">show editor</a>
    </td>
  </tr>
  <!-- Game Report END -->
</table>
</div>
<!-- Additional Details Table END -->

<!-- Alt decision table START -->
<div style="float:left;">
  <table class="adminForm" style="margin: 20px 0 0 5px;">
		<?php
		/* managed inline 
		if ((!isset($overall_config['results_below'])||$overall_config['results_below']==0) &&
		   (!isset($overall_config['edit_results_below'])||$overall_config['edit_results_below']==0)) 
    {
			if($project->allow_add_time)
      { ?>
				<tr>
				<td><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_TYPE; ?>: </td>
				<td><?php echo $mstl; ?></td>
				</tr>
        <?php
      } 
		}
    */
    ?>
		<tr>
			<td width="40%" align="left">
        <?php echo _JL_ADMIN_EDIT_FORM_MATCHES_RESULT_DECISION; ?>
      </td>
	    <td>
        <select style="font-size:9px;" name="alt_decision<?php echo $match->match_id;?>" 
            id="alt_decision<?php echo $match->match_id; ?>" 
            onchange="if (this.selectedIndex==0) {
              document.getElementById('alt_decision_enter<?php echo $match->match_id;?>').style.display='none';
            } else {
              document.getElementById('alt_decision_enter<?php echo $match->match_id;?>').style.display='block';
            }; FormSwitch(<?php echo $match->match_id;?>, this.options[this.selectedIndex].value)">
		      <option value="0"<?php if ($match->alt_decision==0) echo ' selected="selected"' ?>><?php echo _CMN_NO ?></option>
		      <option value="1"<?php if ($match->alt_decision==1) echo ' selected="selected"' ?>><?php echo _CMN_YES ?></option>
		    </select>
    	</td>
	  </tr>
	  <tr>
      <td colspan="2">
        <div id="alt_decision_enter<?php echo $match->match_id;?>" style="display:<?php echo ($match->alt_decision==0) ? 'none' : 'block';?>">
          <table>
            <tr>
              <td align="left"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HOME_NEW;?></td>
							<td><input type="text" style="font-size:9px;" class="inputbox" id="matchpart1_result_decision<?php echo $match->match_id;
								?>" name="matchpart1_result_decision<?php echo $match->match_id;?>" size="3" value="<?php
								if ($match->alt_decision == 1) if (isset($match->matchpart1_result_decision)) echo $match->matchpart1_result_decision; else echo 'X'; ?>" <?php
								if ($match->alt_decision == 0) echo 'DISABLED ' ?>/>
							</td>
						</tr>
					  <tr>
				      <td align="left"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_AWAY_NEW;?></td>
				      <td><input type="text" style="font-size:9px;" class="inputbox" id="matchpart2_result_decision<?php echo $match->match_id;
				      ?>" name="matchpart2_result_decision<?php echo $match->match_id;?>" size="3" value="<?php
				      if ($match->alt_decision == 1) if (isset($match->matchpart2_result_decision)) echo $match->matchpart2_result_decision; else echo 'X'; ?>" <?php
				      if ($match->alt_decision == 0) echo 'DISABLED ' ?>/></td>
				    </tr>
				    <tr>
				      <td align="left"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_NOTICE_NEW;?></td><?php
				      if (is_null($match->matchpart1_result) or ($match->alt_decision == 0)) $disinfo='DISABLED '; ?>
				      <td><input type="text" style="font-size:9px;" class="inputbox" id="decision_info<?php echo $match->match_id;
				      ?>" name="decision_info<?php echo $match->match_id;?>" size="30" value="<?php if ($match->alt_decision == 1) echo $match->decision_info; ?>" <?php
				      if ($match->alt_decision == 0) echo 'DISABLED ' ?>/></td>
				    </tr>
				    <tr>
				      <td align="left"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_COUNT_MATCH;?></td>
				      <td><?php echo mosHTML::yesnoRadioList('count_result'.$match->match_id, '', $match->count_result );?></td>
				    </tr>
				  </table>
        </div>
			</td>
		</tr>
	</table>
</div>


